Skip to content

Fix UsesType precondition pattern in KotlinTestMethodsShouldReturnUnit#1022

Merged
timtebeek merged 1 commit into
mainfrom
fix-usestype-pattern-kotlin-unit
Jun 16, 2026
Merged

Fix UsesType precondition pattern in KotlinTestMethodsShouldReturnUnit#1022
timtebeek merged 1 commit into
mainfrom
fix-usestype-pattern-kotlin-unit

Conversation

@timtebeek

@timtebeek timtebeek commented Jun 16, 2026

Copy link
Copy Markdown
Member

The seven KotlinTestMethodsShouldReturnUnitTest tests started failing with "Recipe was expected to make a change but made no changes."

  • The recipe gated its visitor behind new UsesType<>("org..* *Test*", true). UsesType matches against fully qualified type names, but "org..* *Test*" is the two-token <owner> <name> form that AnnotationMatcher/MethodMatcher understand — no type name contains a space, so it could only ever match via the TypeNameMatcher bug where a ..* token followed by a suffix matched every name. That bug was fixed upstream in Fix TypeNameMatcher ..* followed by a suffix matching every name rewrite#8012, which correctly tightened the matcher and exposed this latent issue.

Uses a valid single-token glob org.junit..*Test* for the UsesType precondition, covering @Test, @ParameterizedTest, @RepeatedTest, and @TestTemplate. The AnnotationMatcher pattern (which correctly supports the two-token form) is left unchanged.

Validated locally with JDK 21 against the current rewrite snapshot: KotlinTestMethodsShouldReturnUnitTest passes (8/8), and the full ./gradlew test is green (1599 tests, 0 failures).

UsesType matches against fully qualified type names, but the precondition was
given the two-token "org..* *Test*" pattern that AnnotationMatcher uses. That
only ever matched because of a TypeNameMatcher bug where a ..* token followed by
a suffix matched every name, fixed upstream in #8012. Use a valid single-token
glob org.junit..*Test* for the UsesType precondition; the AnnotationMatcher
pattern is unchanged.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 16, 2026
@timtebeek timtebeek merged commit c9cd3bd into main Jun 16, 2026
1 check passed
@timtebeek timtebeek deleted the fix-usestype-pattern-kotlin-unit branch June 16, 2026 12:19
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant